package com.photovoltaic.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.photovoltaic.auth.entity.UserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {
    /**
     * 根据用户ID获取该用户的所有角色ID
     *
     * @param userId 用户ID
     * @return 该用户的角色ID列表
     */
    @Select("SELECT role_id FROM user_role WHERE user_id = #{userId}")
    List<Long> getUserRoles(@Param("userId") Long userId);
} 